home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
dvivga9.zip
/
PRTPAGE.H
< prev
next >
Wrap
Text File
|
1988-08-15
|
11KB
|
388 lines
/* -*-C-*- prtpage.h */
/*-->prtpage*/
/**********************************************************************/
/****************************** prtpage *******************************/
/**********************************************************************/
void
prtpage(bytepos) /* print page whose BOP is at bytepos */
long bytepos;
{
struct stack_entry
{
INT32 h;
COORDINATE hh;
INT32 v;
COORDINATE vv;
INT32 w, x, y, z; /* what's on stack */
};
register BYTE command; /* current command */
register INT16 i; /* command parameter; loop index */
unsigned char tc, ex; /* temporary character */
UNSIGN32 ht_rule; /* rule height */
UNSIGN32 wd_rule; /* rule width */
INT32 k,m; /* temporary parameter */
BOOLEAN seen_bop; /* flag for noting processing of BOP */
register INT16 sp; /* stack pointer */
struct stack_entry stack[STACKSIZE]; /* stack */
char specstr[MAXSPECIAL+1]; /* \special{} string */
INT32 w; /* current horizontal spacing */
INT32 x; /* current horizontal spacing */
INT32 y; /* current vertical spacing */
INT32 z; /* current vertical spacing */
unsigned int keyhit, testcycle;
/***********************************************************************
Process all commands between the BOP at bytepos and the next BOP or
POST. The page is printed when the EOP is met, but font changes can
also happen between EOP and BOP, so we have to keep going after EOP.
***********************************************************************/
seen_bop = FALSE; /* this is first time through */
(void) FSEEK(dvifp,bytepos,0); /* start at the desired position */
for (testcycle = 0; 1 ; testcycle++)
/*infinite" loop - exits when POST or second BOP met */
{
command = (BYTE)nosignex(dvifp,(BYTE)1);
#if ( BBNBITGRAPH | VGASCREEN)
/* If the test here on every byte proves to carry objectionable
overhead, it can be moved into the default, PUTx, and SETx
command sections. The goal is to give the user instant
response in page screen positioning, without having to wait
for the entire screen to be painted when it is just going
to be moved anyway. This is the sort of display algorithm
that EMACS uses. */
#if BBNBITGRAPH
if (kbinput() > 0) /* user has typed something */
command = EOP; /* so set for end-of-page action */
#else
if(testcycle == 4) {
testcycle = 0;
if( keyhit = _bios_keybrd(_KEYBRD_READY)) {
tc = (unsigned char)keyhit;
ex = keyhit >> 8;
if(tc == 0 ) {
switch(ex) {
case 72:
firstlinepage -= 96;
if(firstlinepage < MINM) firstlinepage = MINM;
(void)getch();
(void)getch();
break;
case 80:
firstlinepage += 96;
if(firstlinepage > maxm) firstlinepage = maxm;
(void)getch();
(void)getch();
break;
case 71:
case 79:
case 75:
case 77:
case 81:
case 73:
command = EOP;
brokenprtpage = 1;
break;
default:
(void)getch();
(void)getch();
}
} else {
switch(tc) {
case 'q':
case 'Q':
case 'x':
case 'X':
case '\003':
case '\031':
(void)devterm();
(void)dviterm();
(void)alldone(); /* this never returns */
case 'r':
case 'R':
case 'l':
case 'L':
case 'd':
case 'D':
case 'U':
case 'u':
case '\r':
case '\n':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'b':
case 'B':
case 's':
case 'S':
command = EOP;
brokenprtpage = 1;
break;
default:
(void)getch();
}
}
}
}
#endif
#endif
switch (command)
{
case SET1:
case SET2:
case SET3:
case SET4:
(void)setchar((BYTE)nosignex(dvifp,(BYTE)(command-SET1+1)),TRUE);
break;
case SET_RULE:
ht_rule = nosignex(dvifp,(BYTE)4);
wd_rule = nosignex(dvifp,(BYTE)4);
(void)setrule(ht_rule,wd_rule,TRUE);
break;
case PUT1:
case PUT2:
case PUT3:
case PUT4:
(void)setchar((BYTE)nosignex(dvifp,(BYTE)(command-PUT1+1)),FALSE);
break;
case PUT_RULE:
ht_rule = nosignex(dvifp,(BYTE)4);
wd_rule = nosignex(dvifp,(BYTE)4);
(void)setrule(ht_rule,wd_rule,FALSE);
break;
case NOP:
break;
case BOP:
if (seen_bop)
return; /* we have been here already */
seen_bop = TRUE;
for (i=0; i<=9; i++)
tex_counter[i] = (INT32)signex(dvifp,(BYTE)4);
#if BBNBITGRAPH
(void)bopact(); /* display menu at top of page */
#else /* not BBNBITGRAPH */
#if (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT)
(void)bopact();
#else /* NOT (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */
(void)clrbmap();
#endif /* (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */
if (!quiet)
(void)fprintf(stderr,"{%s}",tctos()); /* TeX page counters */
(void) nosignex(dvifp,(BYTE)4); /* skip prev. page ptr */
#endif /* BBNBITGRAPH */
h = v = w = x = y = z = 0;
hh = lmargin;
vv = tmargin;
sp = 0;
fontptr = (struct font_entry*)NULL;
break;
case EOP:
#if (BBNBITGRAPH | CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT)
(void)eopact();
#else
(void)prtbmap();
#endif /* (BBNBITGRAPH | CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */
return;
case PUSH:
if (sp >= STACKSIZE)
(void)fatal("prtpage(): stack overflow");
stack[sp].h = h;
stack[sp].hh = hh;
stack[sp].v = v;
stack[sp].vv = vv;
stack[sp].w = w;
stack[sp].x = x;
stack[sp].y = y;
stack[sp].z = z;
sp++;
break;
case POP:
--sp;
if (sp < 0)
(void)fatal("prtpage(): stack underflow");
h = stack[sp].h;
hh = stack[sp].hh;
v = stack[sp].v;
vv = stack[sp].vv;
w = stack[sp].w;
x = stack[sp].x;
y = stack[sp].y;
z = stack[sp].z;
break;
case RIGHT1:
case RIGHT2:
case RIGHT3:
case RIGHT4:
(void)moveover(signex(dvifp,(BYTE)(command-RIGHT1+1)));
break;
case W0:
(void)moveover(w);
break;
case W1:
case W2:
case W3:
case W4:
w = (INT32)signex(dvifp,(BYTE)(command-W1+1));
(void)moveover(w);
break;
case X0:
(void)moveover(x);
break;
case X1:
case X2:
case X3:
case X4:
x = (INT32)signex(dvifp,(BYTE)(command-X1+1));
(void)moveover(x);
break;
case DOWN1:
case DOWN2:
case DOWN3:
case DOWN4: